package com.betterjr.modules.commission.entity;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.mapper.CustDateJsonSerializer;
import com.betterjr.common.mapper.CustTimeJsonSerializer;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.common.utils.BetterDateUtils;
import com.betterjr.modules.account.entity.CustOperatorInfo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Access(AccessType.FIELD)
@Entity
@Table(name = "T_CPS_FILE_DOWN_HISTORY")
public class CommissionFileDownHistory implements BetterjrEntity {

    /** 
     * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) 
     */
    private static final long serialVersionUID = -6319841639130528125L;

    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    private Long id;

    // 下载文件id
    @Column(name = "L_FILE_DOWN_ID", columnDefinition = "INTEGER")
    private Long fileDownId;

    // 文件名字
    @Column(name = "C_FILE_NAME", columnDefinition = "VARCHAR")
    private String fileName;

    // 操作员ID
    @Column(name = "L_REG_OPERID", columnDefinition = "INTEGER")
    private Long regOperId;

    // 操作员姓名
    @Column(name = "C_REG_OPERNAME", columnDefinition = "VARCHAR")
    private String regOperName;

    // 操作员所在企业
    @Column(name = "C_REG_OPER_ENTERPRISE", columnDefinition = "VARCHAR")
    private String regOperEnterprise;

    // 下载日期
    @Column(name = "C_DOWN_DATE", columnDefinition = "VARCHAR")
    @JsonSerialize(using = CustDateJsonSerializer.class)
    private String downDate;

    // 下载时间
    @Column(name = "C_DOWN_TIME", columnDefinition = "VARCHAR")
    @JsonSerialize(using = CustTimeJsonSerializer.class)
    private String downTime;

    public Long getId() {
        return id;
    }

    public void setId(Long anId) {
        id = anId;
    }

    public Long getFileDownId() {
        return fileDownId;
    }

    public void setFileDownId(Long anFileDownId) {
        fileDownId = anFileDownId;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String anFileName) {
        fileName = anFileName;
    }

    public Long getRegOperId() {
        return regOperId;
    }

    public void setRegOperId(Long anRegOperId) {
        regOperId = anRegOperId;
    }

    public String getRegOperName() {
        return regOperName;
    }

    public void setRegOperName(String anRegOperName) {
        regOperName = anRegOperName;
    }

    public String getRegOperEnterprise() {
        return regOperEnterprise;
    }

    public void setRegOperEnterprise(String anRegOperEnterprise) {
        regOperEnterprise = anRegOperEnterprise;
    }

    public String getDownDate() {
        return downDate;
    }

    public void setDownDate(String anDownDate) {
        downDate = anDownDate;
    }

    public String getDownTime() {
        return downTime;
    }

    public void setDownTime(String anDownTime) {
        downTime = anDownTime;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (downDate == null ? 0 : downDate.hashCode());
        result = prime * result + (downTime == null ? 0 : downTime.hashCode());
        result = prime * result + (fileDownId == null ? 0 : fileDownId.hashCode());
        result = prime * result + (fileName == null ? 0 : fileName.hashCode());
        result = prime * result + (id == null ? 0 : id.hashCode());
        result = prime * result + (regOperEnterprise == null ? 0 : regOperEnterprise.hashCode());
        result = prime * result + (regOperId == null ? 0 : regOperId.hashCode());
        result = prime * result + (regOperName == null ? 0 : regOperName.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        final CommissionFileDownHistory other = (CommissionFileDownHistory) obj;
        if (downDate == null) {
            if (other.downDate != null) return false;
        } else if (!downDate.equals(other.downDate)) return false;
        if (downTime == null) {
            if (other.downTime != null) return false;
        } else if (!downTime.equals(other.downTime)) return false;
        if (fileDownId == null) {
            if (other.fileDownId != null) return false;
        } else if (!fileDownId.equals(other.fileDownId)) return false;
        if (fileName == null) {
            if (other.fileName != null) return false;
        } else if (!fileName.equals(other.fileName)) return false;
        if (id == null) {
            if (other.id != null) return false;
        } else if (!id.equals(other.id)) return false;
        if (regOperEnterprise == null) {
            if (other.regOperEnterprise != null) return false;
        } else if (!regOperEnterprise.equals(other.regOperEnterprise)) return false;
        if (regOperId == null) {
            if (other.regOperId != null) return false;
        } else if (!regOperId.equals(other.regOperId)) return false;
        if (regOperName == null) {
            if (other.regOperName != null) return false;
        } else if (!regOperName.equals(other.regOperName)) return false;
        return true;
    }

    @Override
    public String toString() {
        return "CommissionFileDownHistory [id=" + id + ", fileDownId=" + fileDownId + ", fileName=" + fileName
                + ", regOperId=" + regOperId + ", regOperName=" + regOperName + ", regOperEnterprise="
                + regOperEnterprise + ", downDate=" + downDate + ", downTime=" + downTime + "]";
    }

    public void saveDownHistoryInit(CustOperatorInfo anOperatorInfo) {
        this.id = SerialGenerator.getLongValue("CommissionFileDownHistory.id");
        this.regOperId = anOperatorInfo.getId();
        this.regOperName = anOperatorInfo.getName();
        this.regOperEnterprise = anOperatorInfo.getOperOrg();
        this.downDate = BetterDateUtils.getNumDate();
        this.downTime = BetterDateUtils.getNumTime();
    }

}
